package com.electromagnetic.industry.software.manage.controller;

import com.electromagnetic.industry.software.common.annotations.UserOperation;
import com.electromagnetic.industry.software.common.enums.UserOperationModuleEnum;
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
import com.electromagnetic.industry.software.manage.pojo.req.TagCreateDTO;
import com.electromagnetic.industry.software.manage.service.FileTagRelationService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/data/ed/user/tag")
public class UserEdFileTagController {

    @Resource
    private FileTagRelationService fileTagRelationService;

    // 批量添加标签到文件
    @PostMapping("/addTagsToFile")
    @UserOperation(value = "批量添加了标签到文件", modelName = UserOperationModuleEnum.TAG)
    public ElectromagneticResult<?> addTagsToFile(@RequestBody TagCreateDTO dto) {
        String createdBy = UserThreadLocal.getUserId();
        return ElectromagneticResultUtil.success(fileTagRelationService.addTagsToFile(dto.getFileId(), dto.getTagIds(), createdBy));
    }
}
